"""
活动中心管理后台配置
"""

from django.contrib import admin
from django.utils.html import format_html
from .models import Club, ClubMember, Activity


@admin.register(Club)
class ClubAdmin(admin.ModelAdmin):
    """
    社团管理
    """
    
    list_display = [
        'name', 'category', 'member_count', 'status', 
        'is_verified', 'founded_date', 'created_at'
    ]
    
    list_filter = ['status', 'is_verified', 'category', 'created_at']
    
    search_fields = ['name', 'description', 'contact_person']
    
    ordering = ['-member_count', 'name']
    
    fieldsets = (
        ('基本信息', {
            'fields': ('name', 'description', 'logo')
        }),
        ('社团信息', {
            'fields': ('category', 'founded_date')
        }),
        ('联系方式', {
            'fields': ('contact_person', 'contact_phone', 'contact_email')
        }),
        ('状态设置', {
            'fields': ('status', 'is_verified')
        }),
    )


@admin.register(ClubMember)
class ClubMemberAdmin(admin.ModelAdmin):
    """
    社团成员管理
    """
    
    list_display = ['user', 'club', 'role', 'join_date', 'is_active']
    
    list_filter = ['role', 'is_active', 'join_date']
    
    search_fields = ['user__username', 'club__name']
    
    ordering = ['-join_date']
    
    fieldsets = (
        ('成员信息', {
            'fields': ('user', 'club', 'role')
        }),
        ('状态设置', {
            'fields': ('is_active',)
        }),
    )


@admin.register(Activity)
class ActivityAdmin(admin.ModelAdmin):
    """
    活动管理
    """
    
    list_display = [
        'title', 'club', 'activity_type', 'status', 
        'start_time', 'end_time', 'created_at'
    ]
    
    list_filter = ['status', 'activity_type', 'start_time', 'created_at']
    
    search_fields = ['title', 'description', 'club__name']
    
    ordering = ['-created_at']
    
    fieldsets = (
        ('基本信息', {
            'fields': ('title', 'description', 'club')
        }),
        ('活动信息', {
            'fields': ('activity_type', 'start_time', 'end_time', 'location', 'capacity')
        }),
        ('状态设置', {
            'fields': ('status',)
        }),
    )
